<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@next"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
  <style>
    .list-complete-item {
      transition: all 0.8s ease;
      display: inline-block;
      margin-right: 10px;
    }
    .list-complete-leave-active {
      position: absolute;
    }

    .list-complete-enter-from,
    .list-complete-leave-to {
      opacity: 0;
      transform: translateY(30px);
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click="shuffle">shuffle</button>
    <button @click="add">Add</button>
    <button @click="remove">Remove</button>
    <transition-group name="list-complete" tag="p">
      <span v-for="item in items" :key="item" class="list-complete-item">
        {{ item }}
      </span>
    </transition-group>
  </div>

  <script>
    const app = Vue.createApp({
      setup() {
        let items = Vue.reactive([1, 2, 3, 4, 5, 6, 7, 8, 9])
        let nextNum = Vue.ref(10)
        let randomIndex = () => {
          return Math.floor(Math.random() * items.length)
        }
        let add = () => {
          items.splice(randomIndex(), 0, nextNum.value++)
        }
        let remove = () => {
          items.splice(randomIndex(), 1)
        }
        let shuffle = () => {
          items = shuffle(items)
        }
        return {
          items,
          nextNum,
          add,
          remove,
          shuffle
        }
      }
    })

    app.mount('#app')
  </script>
</body>
</html>